﻿using Microsoft.Extensions.Caching.StackExchangeRedis;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Qianke.Core.Common.NameMutex;
using Volo.Abp.Caching;
using Volo.Abp.Caching.StackExchangeRedis;
using Volo.Abp.Modularity;

namespace Qianke.Core.Common
{

    [DependsOn(
        typeof(AbpCachingStackExchangeRedisModule))]
    public class QiankeCommonModule : AbpModule
    {
        public override void ConfigureServices(ServiceConfigurationContext context)
        {
            var configurantion = context.Services.GetConfiguration();
            Configure<AbpDistributedCacheOptions>(options =>
            {
                options.KeyPrefix = "Qianke";
                options.GlobalCacheEntryOptions = new Microsoft.Extensions.Caching.Distributed.DistributedCacheEntryOptions()
                {
                    SlidingExpiration = System.TimeSpan.FromMinutes(30),
                };
                options.HideErrors = true;
            });
            Configure<NameMutexOptions>(configurantion.GetSection(nameof(NameMutexOptions)));
        }
    }
}
